package flc.ast.dialog;

import android.content.Context;
import android.graphics.Color;
import android.view.Gravity;
import android.view.View;

import androidx.annotation.NonNull;

import com.bigkoo.pickerview.adapter.ArrayWheelAdapter;
import com.contrarywind.adapter.WheelAdapter;
import com.contrarywind.view.WheelView;

import java.util.ArrayList;
import java.util.List;

import flc.ast.R;
import flc.ast.databinding.DialogEducationBgBinding;
import stark.common.basic.base.BaseSmartDialog;

public class EducationBgDialog extends BaseSmartDialog<DialogEducationBgBinding> implements View.OnClickListener {

    private List<String> listEducation = new ArrayList<>();

    public EducationBgDialog(@NonNull Context context) {
        super(context);
    }

    @Override
    protected int getGravity() {
        return Gravity.BOTTOM;
    }

    @Override
    protected int getLayoutId() {
        return R.layout.dialog_education_bg;
    }

    @Override
    protected void initView(View view) {
        mDataBinding.tvCancel.setOnClickListener(this);
        mDataBinding.tvConfirm.setOnClickListener(this);

        mDataBinding.wheelView.setDividerColor(Color.parseColor("#F0F0F0"));
        mDataBinding.wheelView.setTextColorCenter(Color.parseColor("#2262D0"));
        mDataBinding.wheelView.setTextColorOut(Color.parseColor("#CECECE"));
        mDataBinding.wheelView.setLineSpacingMultiplier(2.5f);
        mDataBinding.wheelView.setDividerType(WheelView.DividerType.WRAP);
        mDataBinding.wheelView.setCurrentItem(0);
        mDataBinding.wheelView.setItemsVisibleCount(4);
        mDataBinding.wheelView.setCyclic(false);
        mDataBinding.wheelView.setTextSize(16);
        //设置滚轮数据
        listEducation.add(getContext().getString(R.string.education_bg_text1));
        listEducation.add(getContext().getString(R.string.education_bg_text2));
        listEducation.add(getContext().getString(R.string.education_bg_text3));
        listEducation.add(getContext().getString(R.string.education_bg_text4));
        WheelAdapter adapter = new ArrayWheelAdapter(listEducation);
        mDataBinding.wheelView.setAdapter(adapter);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.tvCancel:
                dismiss();
                break;
            case R.id.tvConfirm:
                dismiss();
                if (listener != null) {
                    listener.clickConfirm(listEducation.get(mDataBinding.wheelView.getCurrentItem()));
                }
                break;
            default:
                break;
        }
    }

    private Ilistener listener;

    public void setListener(Ilistener listener) {
        this.listener = listener;
    }

    public interface Ilistener {
        void clickConfirm(String education);
    }
}
